package com.tuozixuan.singleton1;;

/**
 * 同步锁单例模式<br/>
 * 向getInstance方法的声明中添加synchronized关键字以保证其线程安全<br/>
 * 
 * @see Singleton
 * @author tuozixuan
 *
 */
public class SingletonSync {
	
	private static SingletonSync instance;
	
	private SingletonSync() {
		System.out.println("Something is Instantiated.");
	}
	
	public synchronized static SingletonSync getInstance() {
		if (instance == null) {
			instance = new SingletonSync();
		}
		return instance;
	}
	
	public void doSomething() {
		System.out.println("Something is Done.");
		
	}
}
